import MyTree.TreeNode;
dynamic class MyTree.MTree{
	private var $xOffset:Number;
	private var $yOffset:Number;
	private var $picNodeWidth:Number;
	private var $picNodeHeidht:Number;
	
	private var $nodeIndex:Number=0;
	
	private var $rootNode:TreeNode;
	private var $say:Say;
	/////////////////////////////////////////////////////////
	public function get _Say():Say{
		return this.$say;
	}
	//node root
	public function get RootNode():TreeNode{
		return this.$rootNode;
	}
	public function set RootNode(value:TreeNode){
		this.$rootNode=value;
	}
	// node width
	public function get NodeInde():Number{
		return ++this.$nodeIndex;
	}
	// node width
	public function get PicNodeWidth():Number{
		return this.$picNodeWidth;
	}
	public function set PicNodeWidth(value:Number){
		this.$picNodeWidth=value;
	}
	// node height
	public function get PicNodeHeight():Number{
		return this.$picNodeHeidht;
	}
	public function set PicNodeHeight(value:Number){
		this.$picNodeHeidht=value;
	}
	// node XOffset
	public function get XOffset():Number{
		return this.$xOffset;
	}
	public function set XOffset(value:Number){
		this.$xOffset=value;
	}
	// node YOffset
	public function get YOffset():Number{
		return this.$yOffset;
	}
	public function set YOffset(value:Number){
		this.$yOffset=value;
	}
	////////////////////////////////////////////////
	public function MTree(){
		initSay();
		initvars();
	}
	private function initSay(){
		if(this.$say==undefined){
			this.$say=new Say("Tree");
		}
	}
	private function initvars(){
		this.$nodeIndex=0;
		this.$picNodeHeidht=20;
		this.$picNodeWidth=40;
		this.$xOffset=10;
		this.$yOffset=40;
		this.$rootNode=new TreeNode(this);
	}
	
	public static function GetLevelNodesArray(nd:TreeNode,_level:Number,_arr:Array):Array{
		if(_arr==undefined){
			_arr=new Array();
		}
		if(_level==undefined || _level<0){
			_level=0;
		}
		if(_arr[_level]==undefined){
			_arr[_level]=[nd];
		}else{
			_arr[_level].push(nd);
		}
		for(var i=0;i<nd.Child.length;i++){
			GetLevelNodesArray(nd.Child[i],_level+1,_arr);
		}
		return _arr;
	}
}